喜欢三叶草,但是有时候太贵了不舍得出手,就想着等价格再低一点。
但坑爹的是三叶草官网没有价格提醒。
怎么办呢?
自己写个程序定时去抓吧。源码👇
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
@click.command()
@click.option('--exprice', default=800,
prompt='expected_price', help='期望价格')
@click.argument('artnos', nargs=-1)
def get_price(artnos, exprice):
article_nos = artnos
expected_price = exprice
for article_no in article_nos:
res = requests.get(URL+article_no)
bea = BeautifulSoup(res.content)
divs = bea.find_all('div', class_='pdpInfo')
price = divs[0].div.div.div.p.span.contents[0]
price = price[1:].replace(',', '')
price = float(price)
if price < expected_price:
print(price)
send_mail(article_no, expected_price, price)
|
Python太适合干这种事了😂。